package top.zhangjianyong.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zhangjianyong.tools.service.api.GuagualeService;
import top.zhangjianyong.tools.utils.ApiResponse;

/**
 * @author ： zhangjianyong
 * @date ： 2023/3/13 9:19 AM
 */
@RestController
@RequestMapping("/guaguale")
public class GuagualeController {

    @Autowired
    private GuagualeService guagualeService;

    @PostMapping("/list")
    public ApiResponse list() {
        return guagualeService.listLimit(20);
    }

    @PostMapping("/save/{type}/{code}/{ticketPrice}/{bonus}")
    public ApiResponse save(@PathVariable("type") String type,
                            @PathVariable("code") String code,
                            @PathVariable("ticketPrice") int ticketPrice,
                            @PathVariable("bonus") int bonus) {

        return guagualeService.save(type, code, ticketPrice, bonus);
    }

    @PostMapping("/del/{id}")
    public ApiResponse del(@PathVariable("id") Long id) {
        return guagualeService.del(id);
    }
}
